// 统一管理咱们项目管理相关的接口
import request from '@/utils/request';
import type { loginForm, loginResponseData, registerForm, registerResponseData, userResponseData, } from './type';
import { GET_TOKEN } from '@/utils/token';


// 统一管理接口
enum API {
    LOGIN_URL = '/base/login',
    REGISTER = '/user/admin_register',
    USERINFO_URL = '/user/getUserInfo',
    ROLEUSER_URL = '/user/getRoleUser',
}

// 暴漏请求函数
// 登录接口方法
export const reqLogin = (data: loginForm) => 
    request.post<any, loginResponseData>(API.LOGIN_URL, data)
// 注册
export const reqRegister = (data: registerForm) =>
     request.post<any, registerResponseData>(API.REGISTER, data)
// 获取用户信息接口
export const getUserInfo = () => 
    request.get<userResponseData>(API.USERINFO_URL,{headers: {"token": GET_TOKEN()}})

// 获取对应角色的所有用户
export const getRoleUsers = (authid: number) =>
    request.get(`${API.ROLEUSER_URL}/${authid}`);
